$(function(){
	$("#changygn").css({"border-bottom":"solid 4px #097c25","height":"60px"});
});

var A = 0;
/******二级导航栏切换*****/
$(function(){	
	if(navMingChen == '药品库存'){
		$("#dhyaopin").trigger('click');
	}else if(navMingChen == '耗材库存'){
		$(".nav-comsumer-goods").trigger('click');
	}else if(navMingChen == '入库管理'){
		$(".rukugl").trigger('click');
	}else if(navMingChen == '药品分批库存'){
		$(".yaopin-pici").trigger('click');
	}else if(navMingChen == '耗材分批库存'){
		$(".haocai-pici").trigger('click');
	}else if(navMingChen == '库存预警'){
		$(".kuc").trigger('click');
	}
});
$("#dhyaopin").click(function(){
	if(A>0){
		//confirm("编辑内容没有保存，是否离开？");
		if(confirm("编辑内容没有保存，是否离开？")){
			A = 0;
			$(".g-left-nav li span").css("border","none");
            $(this).css("border","solid 1px #00b472");
            $("#cedan").html();
            $("#cedan").load(path+"yaopin.jsp");
			return false;
		}else{
			return false;
		};
	};
	$(".g-left-nav li span").css("border","none");
    $(this).css("border","solid 1px #00b472");
	$("#cedan").removeData();
	$("#cedan").load(path+"yaopin.jsp");
});
$(".nav-comsumer-goods").click(function(){
	if(A>0){
		if(confirm("编辑内容没有保存，是否离开？")){
			A = 0;
			$(".g-left-nav li span").css("border","none");
            $(this).css("border","solid 1px #00b472");
            $("#cedan").html();
        	$("#cedan").load(path+"haocai.jsp");
			return false;
		}else{
			return false;
		};
	};
	$(".g-left-nav li span").css("border","none");
    $(this).css("border","solid 1px #00b472");
	$("#cedan").removeData();
	$("#cedan").load(path+"haocai.jsp");
});
$(".shangpinrk").click(function(){
	if(A>0){
		//confirm("编辑内容没有保存，是否离开？");
		if(confirm("编辑内容没有保存，是否离开？")){
			A = 0;
			$(".g-left-nav li span").css("border","none");
            $(this).css("border","solid 1px #00b472");
            $("#cedan").html();
            $("#cedan").load(path+"/views/kucun/kucun-pici/shangpin-ruku.jsp");
			return false;
		}else{
			return false;
		};
	};
	$(".g-left-nav li span").css("border","none");
    $(this).css("border","solid 1px #00b472");
	$("#cedan").removeData();
	$("#cedan").load(path+"/views/kucun/kucun-pici/shangpin-ruku.jsp");
});
$(".yaopin-pici").click(function(){
	if(A>0){
		//confirm("编辑内容没有保存，是否离开？");
		if(confirm("编辑内容没有保存，是否离开？")){
			A = 0;
			$(".g-left-nav li span").css("border","none");
            $(this).css("border","solid 1px #00b472");
            $("#cedan").html();
            $("#cedan").load(path+"yaopin-pici.jsp");
			return false;
		}else{
			return false;
		};
	};
	$(".g-left-nav li span").css("border","none");
    $(this).css("border","solid 1px #00b472");
	$("#cedan").removeData();
	$("#cedan").load(path+"yaopin-pici.jsp");
});
$(".haocai-pici").click(function(){
	if(A>0){
		//confirm("编辑内容没有保存，是否离开？");
		if(confirm("编辑内容没有保存，是否离开？")){
			A = 0;
			$(".g-left-nav li span").css("border","none");
            $(this).css("border","solid 1px #00b472");
            $("#cedan").html();
            $("#cedan").load(path+"haocai-pici.jsp");
			return false;
		}else{
			return false;
		};
	};
	$(".g-left-nav li span").css("border","none");
    $(this).css("border","solid 1px #00b472");
	$("#cedan").removeData();
	$("#cedan").load(path+"haocai-pici.jsp");
});
$(".kuc").click(function(){
	if(A>0){
		//confirm("编辑内容没有保存，是否离开？");
		if(confirm("编辑内容没有保存，是否离开？")){
			A = 0;
			$(".g-left-nav li span").css("border","none");
            $(this).css("border","solid 1px #00b472");
            $("#cedan").html();
            $("#cedan").load(path+"kuc-kucunyj.jsp");
			return false;
		}else{
			return false;
		};
	};
	$(".g-left-nav li span").css("border","none");
    $(this).css("border","solid 1px #00b472");
	$("#cedan").removeData();
	$("#cedan").load(path+"kuc-kucunyj.jsp");
});
$(".rukugl").click(function(){
	if(A>0){
		//confirm("编辑内容没有保存，是否离开？");
		if(confirm("编辑内容没有保存，是否离开？")){
			A = 0;
			$(".g-left-nav li span").css("border","none");
            $(this).css("border","solid 1px #00b472");
            $("#cedan").html();
            window.location.href = "ruku.jsp";
			return false;
		}else{
			return false;
		};
	};
	$(".g-left-nav li span").css("border","none");
    $(this).css("border","solid 1px #00b472");
	$("#cedan").removeData();
	window.location.href = "ruku.jsp";
});

/**
 * 根据文本框中的值查询耗材字典
 * 
 */
var kc_haocaiFlag; 
function getHaocaizd() {
	keyCode = event.which;
	if (keyCode == 38 || keyCode == 40) {
		return;
	}
	var val = $('.dropdown-toggle').val();
	clearTimeout(kc_haocaiFlag);
	kc_haocaiFlag = setTimeout(function () {
		if(isTiaoxingma(val) == 'true') {//扫码开药
			$.ajax({
	    		url: './haocai/getPthaocaiByTxm',
	    		type: 'post',
	    		data: {tiaoxingma: val},
	    		async: false,
	    		success: function (data) {
	    			var str = '';
	    			if(data.length == 1) {
	    				ptmingcheng = data[0].mingcheng;
	    				ptbaozhuanggg = data[0].baozhuanggg;
	    				ptbaozhuangdw=data[0].baozhuangdw;
	    				ptchangjia = data[0].shengchancj;
	    				ptpizhun = data[0].pizhunwh;
	    				pttiaoxingm = data[0].tiaoxingma;
	    				$('#mingcheng').val(ptmingcheng);
	    				$('#baozhuanggg').val(data[0].baozhuanggg);
	    				$('#baozhuangdw').val(data[0].baozhuangdw);
	    				$('#shangpmc').val(data[0].shangpinming || '');
	    				$("label[name='linshou2']").trigger("click");
	    				$('#hc-shengchancj').val(data[0].shengchancj);
	    				$('#pizhunwh').val(data[0].pizhunwh);
	    				$('#kucun').val('');
	    				$('#tiaoxingma').val(data[0].tiaoxingma);
	    				if(data[0].chailingbz == 1) {
	    					$('#linshou1').attr('checked','checked');
	    	    			$('#lbshi').attr('class','f-bz on');
	    				}else{
	    					$('#linshou2').attr('checked','checked');
	    	    			$('#lbfou').attr('class','f-bz on');
	    				}
	    				$('#chailingsl').val(data[0].chailingsl);
	    				if(data[0].chailingdw != null) {
	    					$('#chailingdw').text(data[0].chailingdw);
	    					$('#chailingdw').val(data[0].chailingdw);
	    				}
	    				pthcid=data.id;
	    				$('#ptid').val(data[0].id);
	    			} else {
	    				if ( data == '') {
//	    					resetHaocaixq();
	    				}
	    				$(data).each(function () {
	    					var shengchancj = this.shengchancj || '';
	    					var baozhuanggg = this.baozhuanggg;
							if(baozhuanggg!=null) {
								if(baozhuanggg.length>10) {
									baozhuanggg = baozhuanggg.substring(0,35)+'...';
								}
								baozhuanggg = '&nbsp;&nbsp;&nbsp;'+ baozhuanggg;
							}else{
								baozhuanggg = '';
							}
							var xianshi = this.mingcheng+baozhuanggg+'&nbsp;&nbsp;&nbsp;'+shengchancj;
	    					str += '<li index="'+this.mingcheng+','+this.id+'">'+xianshi+'</li>';
	    				});
	    				$('#dropdownli').html('');
	    				$('#dropdownli').append(str);
	    			}
	    		}
	    	});
		}else{
			$.ajax({
				url:'./haocai/getpthaocaiBymc',
				type:'post',
				data:{mingcheng:val},
				success:function(data) {
					var str = '';
					if(data != '') {
						$(data).each(function() {
							var mingcheng = this.mingcheng;
							if(mingcheng.length>40) {
								mingcheng = mingcheng.substr(0,40) + '...';
							}
							var shengchancj = this.shengchancj || '';
							var baozhuanggg = this.baozhuanggg;
							if(baozhuanggg!=null) {
								baozhuanggg = '&nbsp;&nbsp;&nbsp;'+ baozhuanggg;
							}else{
								baozhuanggg = '';
							}
							var xianshi = mingcheng +baozhuanggg+'&nbsp;&nbsp;&nbsp;' +shengchancj ;
							if(xianshi.length > 85) {
								xianshi = xianshi.substring(0,100) +'...';
							}
							str+='<li class="xuanzeli" index="'+this.mingcheng+','+this.id+','+this.uuid+'">'+xianshi+'</li>';
						});
					} else {
//						resetHaocaixq();
					}
					if(data.length >= 10){
						str+='<li id="jingqueczsp" style="text-align:right;color:#00b472;padding-right:15px;">查看所有商品信息&gt;&gt;</li>';
					}
					$('#dropdownli').html("");
					$('#dropdownli').html(str);
				}
			});
		}
    }, 200);
}
/**
 * 根据文本框中的值查询药品字典
 */
var kc_yaopinFlag; 
function getYaopinzd() {
	keyCode = event.which;
	if (keyCode == 38 || keyCode == 40) {
		return;
	}
	var val = $('.dropdown-toggle').val();
	clearTimeout(kc_yaopinFlag);
	kc_yaopinFlag = setTimeout(function() {
		if(isTiaoxingma(val) == 'true') {//扫码开药
			$.ajax({
	    		url: './zsyaopin/getPtyapinByTxm',
	    		type: 'post',
	    		data: {tiaoxingma:val},
	    		async: false,
	    		success: function (data) {
	    			console.log(data);
	    			if(data.length == 1) {
						jixing = data[0].jixing;
	    				if(data[0].leixing == 0 ) {
	                  		var leixing="";
	                    }else if(data[0].leixing==1) {
	                    	var leixing="饮片";
                 		$('#baozhuangdw').val('克');
                 		$('#baozhuangdw').parent().find(".dropdown-toggle").css("color","#333");
                 		$("label[name='linshou2']").trigger("click");
	                    }else if(data[0].leixing==2) {
	                    	var leixing="中成药";
	                    }else if(data[0].leixing==3) {
	                    	var leixing="化学制药";
	                    }else if(data[0].leixing==4) {
	                    	var leixing="生物制药";
	                    }else if(data[0].leixing==5) {
	                    	var leixing="其他";
	                    }
	    				ptmingcheng=data[0].mingcheng;
	    				ptleixing=data[0].leixing;
	    				ptbaozhuanggg=data[0].baozhuanggg;
	    				ptbaozhuangdw=data[0].baozhuangdw;
	    				ptchangjia=data[0].shengchancj;
	    				ptpizhun=data[0].pizhunwh;
	    				pttiaoxingm=data[0].tiaoxingma;
	    				$('#mingcheng').val(ptmingcheng);
	    				$('#shangpmc').val(data[0].shangpinming || '');
	    				$('#leixing').text(leixing);
	    				$('#hileixing').val(data[0].leixing);
	    				$('#leixing').css('color','#333');
	    				$('#baozhuanggg').val(data[0].baozhuanggg);
	    				$('#baozhuangdw').val(data[0].baozhuangdw);
	    				$("label[name='linshou2']").trigger("click");
	    				$('#yp-shengchancj').val(data[0].shengchancj);
	    				$('#pizhunwh').val(data[0].pizhunwh);
	    				$('#jixing').val(data[0].jixing);
	    				$('#tiaoxingma').val(data[0].tiaoxingma);
	    				if(data[0].chailingbz==1) {
	    					$('#linshou1').attr('checked','checked');
	    	    			$('#lbshi').attr('class','f-bz on');
	    				}else{
	    					$('#linshou2').attr('checked','checked');
	    	    			$('#lbfou').attr('class','f-bz on');
	    				}
	    				$('#chailingsl').val(data[0].chailingsl);
	    				if(data[0].chailingdw!=null) {
	    					$('#chailingdw').text(data[0].chailingdw);
	    					$('#chailingdw').val(data[0].chailingdw);
	    				}
	    				$('#yongfa').val(data[0].yongfa);
	    				$('#dancijl').val(data[0].dancijl);
	    				if(data.jiliangdw!=null) {
	    					$('#f-dcjl').text(data[0].jiliangdw);
	    					$('#f-dcjl').val(data[0].jiliangdw);
	    				}
	    				$('#yongyaopl').val(data[0].yongyaopl);
	    				$('#morenkyl').val(data[0].morenkyl);
	    				ptyaopinid=data.id;
	    				$('#hipingtaiypid').val(data[0].id);
	    				$('#yizhu').val(data[0].yizhu);
	    				$('#kucun').val('');
	    			}else{
	    				// 未查询出数据 清空页面
	    				if (data == '') {
//	    					resetYaopinxq();
	    				} 
	    				var str = '';
	    				$(data).each(function(){
	    					var shengchancj = this.shengchancj;
	    					if(shengchancj == null) {
	    						shengchancj = "";
	    					}
	    					var baozhuanggg = this.baozhuanggg;
							if(baozhuanggg!=null) {
								if(baozhuanggg.length>10) {
									baozhuanggg = baozhuanggg.substring(0,35)+'...';
								}
								baozhuanggg = '&nbsp;&nbsp;&nbsp;'+ baozhuanggg;
							}else{
								baozhuanggg = '';
							}
							var xianshi = this.mingcheng+baozhuanggg+'&nbsp;&nbsp;&nbsp;'+shengchancj;
	    					str += '<li class="hello xuanzeli" index="'+this.mingcheng+','+this.id+','+this.uuid+'">'+xianshi+'</li>';
	    				});
	    				$('#dropdownli').html('');
	    				$('#dropdownli').append(str);
	    			}
	    		}
	    	});
		}else{
			$.ajax({
				url:'./zsyaopin/getPtyapinBymc',
				type:'post',
				data:{mingcheng:val},
				success:function(data) {
					var str = "";
					if(data != '') {
						$(data).each(function(){
							var shengchancj = this.shengchancj;
							if(shengchancj == null) {
								shengchancj = "";
							}
							var baozhuanggg = this.baozhuanggg;
							if(baozhuanggg!=null) {
								if(baozhuanggg.length>10) {
									baozhuanggg = baozhuanggg.substring(0,35)+'...';
								}
								baozhuanggg = '&nbsp;&nbsp;&nbsp;'+ baozhuanggg;
							}else{
								baozhuanggg = '';
							}
							var shangpinming = this.shangpinming;
							if(shangpinming !=null && shangpinming!='') {
								shangpinming ='&nbsp;&nbsp;&nbsp;'+ '[' + shangpinming + ']';
							}else{
								shangpinming = '';
							}
							var xianshi = this.mingcheng+shangpinming+baozhuanggg+'&nbsp;&nbsp;&nbsp;'+shengchancj;
							str+='<li class="xuanzeli" index="'+this.mingcheng+','+this.id+','+this.uuid+'">'+xianshi+'</li>';
						});
					} else {
//						resetYaopinxq();
					}
					if(data.length >= 10){
						str+='<li id="jingqueczsp" style="text-align:right;color:#00b472;padding-right:15px;">查看所有商品信息&gt;&gt;</li>';
					}
					$('#dropdownli').html("");
					$('#dropdownli').html(str);
				}
			});
		}
    }, 200);
}
/*************************
 *根据文本框中的值查询药品字典结束 
 */
//取消关闭弹窗
$(".cancel").click(function(){
	$("#tanceng-close").modal('hide');
	$("#tanceng-open").modal('hide');
	$("#tanceng-yjclose").modal('hide');
	$("#tanceng-yjopen").modal('hide');
});
//预警开关
var yj_Id = null;
var yp_row = null;
var yj_xx = null;
function yujingkaiqi(id,row_id,kucunxx,r_danwei,preymlx,$this){
	yj_Id = id;
	yp_row = row_id;
	yj_xx = kucunxx;
	ymlx=preymlx;
	$('#danwei').text(r_danwei);
	$this.parent().parent().siblings('tr').removeClass('list-tr');
	if($("#yujingkq"+id).text() == "开启预警"){
		if(yj_xx==""){
		}else{
			$(".f-tc-kucunxx").val(yj_xx);
		}
		//开启预警弹窗及光标定位
		var yujingkqtext;
		if(ymlx==1){
			var yujingkqtext='当前药品是否开启预警';
		}else if(ymlx==2){
			var yujingkqtext='当前耗材是否开启预警';
		}
		$("#yujingkqtext").text(yujingkqtext);
		$("#tanceng-yjopen").modal();
		$("#tanceng-yjopen").on('shown.bs.modal',function(){
			$('#kuxunxx').focus();
		});
	}else{
		var yujinggbtext;
		if(ymlx==1){
			var yujinggbtext='当前药品是否关闭预警';
		}else if(ymlx==2){
			var yujinggbtext='当前耗材是否关闭预警';
		}
		$("#yujinggbtext").text(yujinggbtext);
		$("#tanceng-yjclose").modal();
	}
}
$("#tanceng-yjopen .confirm").on("click",function(){
	if(ymlx==1){
		var url="./zsyaopin/yujingkg";
	}else if(ymlx==2){
		var url="./haocai/yujingkg";
	}
	if($(".f-tc-kucunxx").val()==""){
		 $(".f-tc-kucunxx").addClass("n-invalid");
		 notifyWarning("请输入库存下限");
		 return false;
	}else{
		if($(".f-tc-kucunxx").val().length>8){
			notifyWarning("库存数量最大为8位数字");
			return;
		}
		$(".f-tc-kucunxx").removeClass("n-invalid");
		var id=yj_Id;
		var yujin = 1;
		var sendData ={
				"id":id,
				"yujin":yujin,
				"kucunxx":$('#kuxunxx').val()
		};
		$.ajax({
			 type:"POST",
		        //获取json文件路径
		        url:url,
		        //传送数据
		        data:sendData,
		        //请求成功完成后要执行的方法
		        success: function(data){
					  $("#yujingkq"+id).text("关闭预警");
		        	  $("#tanceng-yjopen").modal('hide');
		        	  notifySuccess('开启库存预警成功');
		        	  yj_Id =null;
		        	  yp_row = null;
		        }
		});
	}
});
$("#tanceng-yjclose .confirm").on("click",function(){
	if(ymlx==1){
		var url="./zsyaopin/yujingkg";
	}else if(ymlx==2){
		var url="./haocai/yujingkg";
	}
	var id=yj_Id;
	var yujin = 0;
	var sendData ={
			"id":id,
			"yujin":yujin,
			"kucunxx":$('#kuxunxx').val()
	}
	$.ajax({
		 type:"POST",//获取json文件路径
	        url:url,
	        data:sendData,
	        success: function(data){
				 $("#yujingkq"+id).text("开启预警")
	        	  $("#tanceng-yjclose").modal('hide');
				  notifySuccess('关闭库存预警成功');
	        	  yj_Id =null;
	        	  yp_row = null;
	        }
	});
});

var qyjy_Id=null;
var qyjy_row = null;
var $this=null;
var pageNo;
var huichefs='chaxun';
/**
 * 列表库存禁用启用方法
 * @param {Object} prepageNo
 * @param {Object} id
 * @param {Object} row_id
 * @param {Object} preymlx
 * @param {Object} pre$this
 */
function jingyongqiyong(prepageNo,id,row_id,preymlx,pre$this){
	pageNo=prepageNo;
	qyjy_Id =id;
	qyjy_row=row_id;
	ymlx=preymlx;
	$this=pre$this;
	if($("#qyjy"+id).text() == "启用"){
		var qiyongtext;
		if(ymlx==1){
			qiyongtext="当前药品是否启用";
		}else{
			qiyongtext="当前耗材是否启用";
		}
		$('#qiyongtext').text(qiyongtext);
		$("#tanceng-open").modal();
		$("#tanceng-open").on('shown.bs.modal',function(){
			huichefs='qiyong';
			$(document).keydown(function(){
				if(event.keyCode==13&&huichefs=='qiyong' && $("#tanceng-close").hasClass('in')){ 
					$("#qiyong").trigger('click');
					huichefs='chaxun';
					return false;
					
				}
			});
		});
	}else{
		var jinyongtext;
		if(ymlx==1){
			jinyongtext="当前药品是否禁用";
		}else{
			jinyongtext="当前耗材是否禁用";
		}
		$('#jinyongtext').text(jinyongtext);
		$("#tanceng-close").modal();
		$("#tanceng-close").on('shown.bs.modal',function(){
			huichefs='jinyong';
			$(document).keydown(function(){
				if(event.keyCode==13&&huichefs=='jinyong' && $("#tanceng-close").hasClass('in')){ 
					huichefs='chaxun';
					$("#jinyong").trigger('click');
					return false;
				}
			});
		});
	}
	$this.parent().parent().siblings('tr').removeClass('list-tr');
}
/*********列表启用库存确定*********/
$('#tanceng-open .confirm').on("click",function(){
	if(ymlx==1){
		var url="./zsyaopin/jinyongyp";
	}else{
		var url="./haocai/jinyongyg";
	}
	var sendData ={
			"id":qyjy_Id,
			"jinyongbz":0
	}
	$.ajax({
		 type:"POST",//获取json文件路径
	        url:url,//传送数据
	        data:sendData,//请求成功完成后要执行的方法
	        success: function(data){
				$("#tanceng-open").modal('hide');
				if(data == 'success') {
		        	pageNumber=pageNo;
		        	notifySuccess('启用库存成功');
		        	exeShowPage();
				}else{
					notifyWarning(data);
				}
	        	  
	        }
	});
});
/*********列表禁用库存确定*********/
$("#tanceng-close .confirm").on("click",function(){
	if(ymlx==1){
		var url="./zsyaopin/jinyongyp";
	}else{
		var url="./haocai/jinyongyg";
	}
	var sendData ={
			"id":qyjy_Id,
			"jinyongbz":1
	}
	$.ajax({
		 type:"POST",
		 	url:url,
	        data:sendData,
	        success: function(data){
	        	  $("#tanceng-close").modal('hide');
	        	  pageNumber=pageNo;
	        	  notifySuccess('禁用库存成功');
	        	  exeShowPage();
	        }
	});
});
/*****************
 * 列表启用库存确定结束 
 */

/*********radio选择*********/
$(".f-bz-tzkc").on("click",function(){
	var radioId= $(this).attr("name");
	$(this).addClass("on").siblings().removeClass("on");
	if($(this).hasClass('on')){
		$("input.f-tiaozhenkc").prop("checked",false); 
		$("#" + radioId).prop("checked",true);
	 }
});

/**
 * 列表点击调整库存
 */
var id;
var kucunsl;//原有库存
var ymlx;//判断从耗材或药品页面进入
function tiaozhengkucun(preid,prekucunsl,prekuncundw,preymlx,$this){
	$("#add-subtraction").val('');
	id=preid;
	kucunsl=prekucunsl;
	ymlx=preymlx;
	$("#add-subtraction").removeClass('n-invalid');
	$("#zengjia").addClass('on');
	$("#jianshao").removeClass('on');
	$("#kucuntzdw").text(prekuncundw);
	$("#tanceng-tzkc").modal();
	$("input.f-tiaozhenkc").prop("checked",false); 
	$("#linshou1").prop("checked",true);
	$("#tanceng-tzkc").on('shown.bs.modal',function(){
		$("#add-subtraction").focus();
	});
	$this.parent().parent().siblings('tr').removeClass('list-tr');
}

/*********库存增减选择时光标定位*********/
$(function(){
	$("#zengjia").click(function () {
		$("#add-subtraction").focus();
	});
	$("#jianshao").click(function () {
		$("#add-subtraction").focus();
	});
});

/*********库存调整数正整数控制判定*********/
$('#add-subtraction').on('input',function(){
	var val=$(this).val();
	var reg = /^-?\d{0,8}\.?\d{0,4}$/ ;
	if(!reg.test(val)){
		notifyWarning("请输入正确位数的数字！");
		$(this).val("");
		return false;
	}
});

/*********调整库存更改按钮确定**********/
$("#tzkc-genggaibtn").click(function(){
	var url;
	var tiaozhengshu = $("#add-subtraction").val();
	var zengjian=$("input.f-tiaozhenkc:checked").val();
	if(tiaozhengshu==''){
		notifyWarning('请输入调整数量');
		$("#add-subtraction").addClass('n-invalid');
		return false;
	}
	if(ymlx==1){
		url="./zsyaopin/tiaozhengkc";
	}else{
		url="./haocai/tiaozhengkc";
	}
	$("#add-subtraction").val('');
	if(zengjian==0) {
		var kucunjsye = parseFloat(kucunsl)-parseFloat(tiaozhengshu);
		if(kucunjsye<0){
			notifyWarning("超出现有库存");
//				kucunsl =0;       
			return false;
		}
		var sendData ={
				"id":id,
				"kucunsl":kucunjsye,
		};
		$.ajax({
			type:"POST",
			url:url,
			data:sendData,//传送数据
			success: function(data){
				exeShowPage();
				$("#tanceng-tzkc").modal('hide');
				notifySuccess('库存修改成功');
				}
			});
	}else{
		var kucunzjye = parseFloat(kucunsl)+parseFloat(tiaozhengshu);
		if((kucunzjye).toString().length>8){
			notifyWarning("库存总数最大为8位数字");
			return;
		}
		var sendData ={
				"id":id,
				"kucunsl":kucunzjye,
		}
		$.ajax({
			 type:"POST",
		        url:url,
		        data:sendData,
		        success: function(data){//请求成功完成后要执行的方法
					notifySuccess('库存修改成功');
		        	  $("#tanceng-tzkc").modal('hide');
		        	  exeShowPage();
		        }
		});
	}
});
/*****************
 * 列表点击调整库存结束
 */


/**
 * 公共方法区
 */

/**正则判断字符数*/
function getByteLen(val) {
	var len = 0;
	for (var i = 0; i < val.length; i++) {
		var a = val.charAt(i);
		if (a.match(/[^\x00-\xff]/ig) != null) {
			len += 2;
		} else {
			len += 1;
		}
	}
	return len;
}

function getFloatStr(num){  
	num += '';  
	num = num.replace(/[^0-9|\.]/g, ''); //清除字符串中的非数字非.字符  
	if(/^0+/) //清除字符串开头的0  
	num = num.replace(/^0+/, '');  
	if(!/\./.test(num)) //为整数字符串在末尾添加.00  
	num += '.00';  
	if(/^\./.test(num)) //字符以.开头时,在开头添加0  
	num = '0' + num;  
	num += '00';        //在字符串末尾补零  
	num = num.match(/\d+\.\d{2}/)[0];  	
	return num;
}; 
  
function getintStr(num){  
	num += '';  
	num = num.replace(/[^0-9|\.]/g, ''); //清除字符串中的非数字非.字符  
	if(/^0+/) //清除字符串开头的0  
	num = num.replace(/^0+/, ''); 
	if(!/\./.test(num)) //为整数字符串在末尾添加.  
	num += '.';  
	if(/^\./.test(num)) //字符以.开头时,在开头添加0  
	num = '0' + num;
	num = parseInt(num);
	return num;
}; 
// 清空药品页面信息
function resetYaopinxq() {
//	jixing = data[0].jixing;
	ptleixing = '';
	ptbaozhuanggg = '';
	ptchangjia = '';
	ptpizhun = '';
	pttiaoxingm = '';
	$('#leixing').text('请选择');
	$('#hileixing').val('0');
	$('#leixing').css('color','#333');
	$('#baozhuanggg').val('');
	$('#baozhuangdw').val('');
	$('#lbfou').attr('class','f-bz on');
	$("label[name='linshou2']").trigger("click");
	$('#shengchancj').val('');
	$('#pizhunwh').val('');
	$('#tiaoxingma').val('');
	$('#chailingsl').val('');
	$('#chailingdw').text('');
	$('#chailingdw').val('');
	$('#yongfa').val('');
	$('#dancijl').val('');
	$('#f-dcjl').text('单位').css('height','34px').css('color','#777').val('');
	$('#yongyaopl').val('');
	$('#morenkyl').val('');
	$('#morenkydw').text('单位').css('height','34px').css('color','#777').val('');
	ptyaopinid='';
	$('#hipingtaiypid').val('');
	$('#yizhu').val('');	
}
// 重置耗材信息
function resetHaocaixq() {
	ptbaozhuanggg = '';
	ptchangjia = '';
	ptpizhun = '';
	pttiaoxingm = '';
	$('#baozhuanggg').val('');
	$('#baozhuangdw').val('');
	$("label[name='linshou2']").trigger("click");
	$('#shengchancj').val('');
	$('#pizhunwh').val('');
	$('#tiaoxingma').val('');
	$('#lbfou').attr('class','f-bz on');
	$('#chailingsl').val('');
	$('#chailingdw').text('');
	$('#chailingdw').val('');
	pthcid = '';
	$('#ptid').val('');	
}